home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Widget Wizard.dir / WidgtBehaviors_40_Multi Member Sprite.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  2.5 KB  |  89 lines

  1. property enabled, membermin, membermax, cycling, goingup, CurrentState, numstates, name
  2.  
  3. on getPropertyDescriptionList
  4.   set description to [:]
  5.   addProp(description, #membermin, [#default: 1, #format: #integer, #comment: "Start of Cast Range:"])
  6.   addProp(description, #membermax, [#default: 1, #format: #integer, #comment: "End of Cast Range:"])
  7.   addProp(description, #CurrentState, [#default: 1, #format: #integer, #comment: "Which image to start with:"])
  8.   addProp(description, #cycling, [#default: 1, #format: #boolean, #comment: "Cycling? (if not, bouncing):"])
  9.   addProp(description, #currentImage, [#default: 1, #format: #boolean, #comment: "Going up? (if not, going down):"])
  10.   addProp(description, #name, [#default: #multistate1, #format: #symbol, #comment: "Name:"])
  11.   return description
  12. end
  13.  
  14. on getBehaviorDescription
  15.   return "When addressed, cycle through cast members"
  16. end
  17.  
  18. on getAssocMembers
  19.   set myPropList to []
  20.   repeat with x = membermin to membermax
  21.     add(myPropList, the name of member x)
  22.   end repeat
  23.   return myPropList
  24. end
  25.  
  26. on beginSprite me
  27.   puppetSprite(the spriteNum of me, 1)
  28.   set the enabled of me to 1
  29.   set the numstates of me to the membermax of me - the membermin of me + 1
  30.   setstate(me, the CurrentState of me)
  31. end
  32.  
  33. on setgoingup me, value
  34.   set the goingup of me to value
  35. end
  36.  
  37. on setcycle me, value
  38.   set the cycling of me to value
  39. end
  40.  
  41. on setstate me, statenum
  42.   if the enabled of me then
  43.     if statenum > the numstates of me then
  44.       set statenum to the numstates of me
  45.     end if
  46.     set the member of sprite the spriteNum of me to statenum + the membermin of me - 1
  47.   end if
  48. end
  49.  
  50. on bumpstate_extern me, name
  51.   if name = the name of me then
  52.     bumpstate(me)
  53.   end if
  54. end
  55.  
  56. on bumpstate me
  57.   if the enabled of me then
  58.     if the cycling of me then
  59.       if the goingup of me then
  60.         set curr to the CurrentState of me + 1
  61.         if curr > the numstates of me then
  62.           set curr to 1
  63.         end if
  64.       else
  65.         set curr to the CurrentState of me - 1
  66.         if curr < 1 then
  67.           set curr to the numstates of me
  68.         end if
  69.       end if
  70.     else
  71.       if the goingup of me then
  72.         set curr to the CurrentState of me + 1
  73.         if curr > the numstates of me then
  74.           set curr to curr - 2
  75.           set the goingup of me to 0
  76.         end if
  77.       else
  78.         set curr to the CurrentState of me - 1
  79.         if curr < 1 then
  80.           set curr to 2
  81.           set the goingup of me to 1
  82.         end if
  83.       end if
  84.     end if
  85.     set the CurrentState of me to curr
  86.     setstate(me, curr)
  87.   end if
  88. end
  89.